// 组件基础类型
export interface IComponent {
  id: string
  type: string
  name: string
  props: Record<string, any>
  children?: IComponent[]
  style?: Record<string, any>
  events?: Record<string, any>
  data?: Record<string, any>
  createdAt?: string // 创建时间
  updatedAt?: string // 最后修改时间
}

// 页面配置类型
export interface IPageConfig {
  id: string
  name: string
  title: string
  components: IComponent[]
  layout: {
    width: number
    height: number
    background?: string
  }
  meta?: Record<string, any>
}

// 组件库类型
export interface IWidgetMeta {
  type: string
  name: string
  icon: string
  category: string
  description: string
  defaultProps: Record<string, any>
  defaultStyle: Record<string, any>
  propSchema: IPropSchema[]
  styleSchema: IStyleSchema[]
}

// 属性配置模式
export interface IPropSchema {
  key: string
  label: string
  type: 'string' | 'number' | 'boolean' | 'select' | 'color' | 'textarea'
  defaultValue?: any
  options?: Array<{ label: string; value: any }>
  required?: boolean
  description?: string
}

// 样式配置模式
export interface IStyleSchema {
  key: string
  label: string
  type: 'string' | 'number' | 'select' | 'color'
  defaultValue?: any
  options?: Array<{ label: string; value: any }>
  unit?: string
}

// 拖拽状态类型
export interface IDragState {
  isDragging: boolean
  dragType: 'new' | 'move' | null // 拖拽类型：新建组件或移动组件
  dragComponent: IComponent | null // 拖拽的组件
  dragSource: 'library' | 'canvas' | null // 拖拽来源：组件库或画布
  dropTarget: IComponent | null // 拖拽目标组件
  dragPosition: { x: number; y: number } // 拖拽位置
  dragOffset: { x: number; y: number } // 拖拽偏移量
  dragStartTime: number // 拖拽开始时间
  dragStartPosition: { x: number; y: number } // 拖拽开始位置
}

// 选中状态类型
export interface ISelectionState {
  selectedComponent?: IComponent
  selectedComponents: IComponent[]
  isMultiSelect: boolean
}

// 历史记录类型
export interface IHistoryRecord {
  id: string
  timestamp: number
  action: string
  data: any
  description: string
}

// 项目类型
export interface IProject {
  id: string
  name: string
  description?: string
  pages: IPageConfig[]
  widgets: IWidgetMeta[]
  createdAt: number
  updatedAt: number
  version: string
} 